using System;
using System.Security.Policy;
using UnityEngine;

namespace Client.Base
{
    public class UniApp : MonoBehaviour
    {
        [SerializeField] private GameObject reporter;
        static public UniApp Instance { get; private set; }
        public event Action onUpdate;
        public event Action onFixedUpdate;
        public event Action onLateUpdate;
        public event Action onDesttroy;
        public event Action<bool> onApplicationFocus;
        public event Action<bool> onApplicationPause;
        public event Action onApplicationQuit;
        public event Action<string> onDeepLinkActivated;
        private void Awake() {
            Instance = this;
            Application.deepLinkActivated += onDeepLinkActivated;
            DontDestroyOnLoad(gameObject);
        } 
        private void Update() => onUpdate?.Invoke();
        private void FixedUpdate() =>onFixedUpdate?.Invoke();
        private void LateUpdate() =>onLateUpdate?.Invoke();
        private void OnDestroy() => onDesttroy?.Invoke();
        private void OnApplicationFocus(bool focus) => onApplicationFocus?.Invoke(focus);
        private void OnApplicationPause(bool pause) => onApplicationPause?.Invoke(pause);
        private void OnApplicationQuit() => onApplicationQuit?.Invoke();

        public void SetReporterActive(bool state) => reporter.SetActive(state);
    }
}

